package com.tre.jdevtemplateboot.web.controller;


import com.tre.jdevtemplateboot.common.dto.PageQuery;
import com.tre.jdevtemplateboot.common.dto.ResponseResult;
import com.tre.jdevtemplateboot.domain.dto.SpAppGroupMstDto;
import com.tre.jdevtemplateboot.domain.vo.SpAppGroupMstVO;
import com.tre.jdevtemplateboot.service.ISpAppGroupMstService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author JDev
 * @since 2023-11-15
 */
@RestController
@RequestMapping("/app/group")
public class SpAppGroupMstController {

    @Autowired
    private ISpAppGroupMstService spAppGroupMstService;

    /**
     * 分页查询分组
     * @param query
     * @return
     */
    @PostMapping
    public ResponseResult<SpAppGroupMstVO> page(PageQuery query){
        return spAppGroupMstService.findGroupByPage(query);
    }

    /**
     * 新增分组
     * @param dto
     * @return
     */
    @PostMapping("/save")
    public ResponseResult save(@RequestBody SpAppGroupMstDto dto){
        return spAppGroupMstService.saveGroup(dto);
    }

    /**
     * 修改分组
     * @param dto
     * @return
     */
    @PostMapping("/update")
    public ResponseResult update(@RequestBody SpAppGroupMstDto dto){
        return spAppGroupMstService.editGroup(dto);
    }


    /**
     * 删除分组
     * @param id
     * @return
     */
    @PostMapping("/del")
    public ResponseResult delete(String id){
        spAppGroupMstService.removeById(id);
        return ResponseResult.buildOK();
    }


}
